<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1 , user-scalable=no">
<title>社团添加</title>
<link href="__PUBLIC__/plugins/bootstrap.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-dashen.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/font-awesome.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/animate.css" rel="stylesheet">
<link href="__PUBLIC__/plugins/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
</head>
<body style="margin-top:70px;">
<div class="container">
{include file="common/header" /}
	<div class="col-md-12 wow fadeInLeft">
		<ul class="breadcrumb">
  			<li><a href="__PUBLIC__/index.php">首页</a></li>
  			<li><a href="__PUBLIC__/Shetuan/frontlist">社团管理</a></li>
  			<li class="active">添加社团</li>
		</ul>
		<div class="row">
			<div class="col-md-10">
		      	<form class="form-horizontal" name="shetuanAddForm" id="shetuanAddForm" enctype="multipart/form-data" method="post"  class="mar_t15">
				  <div class="form-group">
				  	 <label for="shetuan_shetuanName" class="col-md-2 text-right">社团名称:</label>
				  	 <div class="col-md-8">
					    <input type="text" id="shetuan_shetuanName" name="shetuan_shetuanName" class="form-control" placeholder="请输入社团名称">
					 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_shetuanPhoto" class="col-md-2 text-right">社团图片:</label>
				  	 <div class="col-md-8">
					    <img  class="img-responsive" id="shetuan_shetuanPhotoImg" border="0px"/><br/>
					    <input type="hidden" id="shetuan_shetuanPhoto" name="shetuan_shetuanPhoto"/>
					    <input id="shetuanPhotoFile" name="shetuanPhotoFile" type="file" size="50" />
				  	 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_yxzyObj_yxzyId" class="col-md-2 text-right">所在院系专业:</label>
				  	 <div class="col-md-8">
					    <select id="shetuan_yxzyObj_yxzyId" name="shetuan.yxzyObj.yxzyId" class="form-control">
					    </select>
				  	 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_bornDateDiv" class="col-md-2 text-right">成立日期:</label>
				  	 <div class="col-md-8">
		                <div id="shetuan_bornDateDiv" class="input-group date shetuan_bornDate col-md-12" data-link-field="shetuan_bornDate" data-link-format="yyyy-mm-dd">
		                    <input class="form-control" id="shetuan_bornDate" name="shetuan_bornDate" size="16" type="text" value="" placeholder="请选择成立日期" readonly>
		                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
		                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
		                </div>
				  	 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_shetuanDesc" class="col-md-2 text-right">社团简介:</label>
				  	 <div class="col-md-8">
							    <textarea name="shetuan_shetuanDesc" id="shetuan_shetuanDesc" style="width:100%;height:500px;"></textarea>
					 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_fuzeren" class="col-md-2 text-right">负责人:</label>
				  	 <div class="col-md-8">
					    <input type="text" id="shetuan_fuzeren" name="shetuan_fuzeren" class="form-control" placeholder="请输入负责人">
					 </div>
				  </div>
				  <div class="form-group">
				  	 <label for="shetuan_telephone" class="col-md-2 text-right">联系电话:</label>
				  	 <div class="col-md-8">
					    <input type="text" id="shetuan_telephone" name="shetuan_telephone" class="form-control" placeholder="请输入联系电话">
					 </div>
				  </div>
		          <div class="form-group">
		             <span class="col-md-2"></span>
		             <span onclick="ajaxShetuanAdd();" class="btn btn-primary bottom5 top5">添加</span>
		          </div> 
		          <style>#shetuanAddForm .form-group {margin:5px;}  </style>  
				</form> 
			</div>
			<div class="col-md-2"></div> 
	    </div>
	</div>
</div>
{include file="common/footer" /}
<script src="__PUBLIC__/plugins/jquery.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrap.js"></script>
<script src="__PUBLIC__/plugins/wow.min.js"></script>
<script src="__PUBLIC__/plugins/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugins/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="__PUBLIC__/plugins/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
//实例化编辑器
var shetuan_shetuanDesc_editor = UE.getEditor('shetuan_shetuanDesc'); //社团简介编辑器
	//提交添加社团信息
	function ajaxShetuanAdd() { 
		//提交之前先验证表单
		$("#shetuanAddForm").data('bootstrapValidator').validate();
		if(!$("#shetuanAddForm").data('bootstrapValidator').isValid()){
			return;
		}
		if(shetuan_shetuanDesc_editor.getContent() == "") {
			alert('社团简介不能为空');
			return;
		}
		jQuery.ajax({
			type : "post",
			url : "{:url('Shetuan/frontAdd')}",
			dataType : "json" , 
			data: new FormData($("#shetuanAddForm")[0]),
			success : function(obj) {
				if(obj.success){ 
					alert("保存成功！");
					$("#shetuanAddForm").find("input").val("");
					$("#shetuanAddForm").find("textarea").val("");
					shetuan_shetuanDesc_editor.setContent("");
				} else {
					alert(obj.message);
				}
			},
			processData: false, 
			contentType: false, 
		});
	} 
$(function(){
	/*小屏幕导航点击关闭菜单*/
    $('.navbar-collapse a').click(function(){
        $('.navbar-collapse').collapse('hide');
    });
    new WOW().init();
	//验证社团添加表单字段
	$('#shetuanAddForm').bootstrapValidator({
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		},
		fields: {
			"shetuan_shetuanName": {
				validators: {
					notEmpty: {
						message: "社团名称不能为空",
					}
				}
			},
			"shetuan_bornDate": {
				validators: {
					notEmpty: {
						message: "成立日期不能为空",
					}
				}
			},
			"shetuan_fuzeren": {
				validators: {
					notEmpty: {
						message: "负责人不能为空",
					}
				}
			},
			"shetuan_telephone": {
				validators: {
					notEmpty: {
						message: "联系电话不能为空",
					}
				}
			},
		}
	}); 
	//初始化所在院系专业下拉框值 
	$.ajax({
		url: "{:url('Yxzy/listAll')}",
		type: "get",
		dataType : "json" ,
		success: function(yxzys,response,status) { 
			$("#shetuan_yxzyObj_yxzyId").empty();
			var html="";
    		$(yxzys).each(function(i,yxzy){
    			html += "<option value='" + yxzy.yxzyId + "'>" + yxzy.yxzyName + "</option>";
    		});
    		$("#shetuan_yxzyObj_yxzyId").html(html);
    	}
	});
	//成立日期组件
	$('#shetuan_bornDateDiv').datetimepicker({
		language:  'zh-CN',  //显示语言
		format: 'yyyy-mm-dd',
		minView: 2,
		weekStart: 1,
		todayBtn:  1,
		autoclose: 1,
		minuteStep: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0
	}).on('hide',function(e) {
		//下面这行代码解决日期组件改变日期后不验证的问题
		$('#shetuanAddForm').data('bootstrapValidator').updateStatus('shetuan_bornDate', 'NOT_VALIDATED',null).validateField('shetuan_bornDate');
	});
})
</script>
</body>
</html>
